package com.scau.beyondboy.dao.impl;
import com.scau.beyondboy.dao.UserDao;
import com.scau.beyondboy.model.UserEntity;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * Author:beyondboy
 * Gmail:xuguoli.scau@gmail.com
 * Date: 2015/12/11
 * Time: 0:22
 */
@Repository(value = "userDao")
@Transactional
public class UserDaoImpl extends BaseDaoImpl<UserEntity> implements UserDao
{
    public static final String CHECKLOGIN = "from UserEntity user where user.username=? and user.password=?";
    public static final String ADDCHECK="from UserEntity user where user.username=?";
    
    @Override
    @Transactional
    public List<UserEntity> findUser(String username)
    {
        return find(ADDCHECK,username);
    }
    @Override
    public List<UserEntity> checkUser(String username, String password)
    {
        return find(CHECKLOGIN,username,password);
    }
    @Override
    @Transactional
    public void addUser(String username, String password) {
        UserEntity userEntity=new UserEntity();
        userEntity.setUsername(username);
        userEntity.setPassword(password);
        saveOrUpdate(userEntity);
    }
}
